#-*- coding: utf-8 -*-

"""
    Copyright 2010 Kacper Żuk <kaz@boo.pl>
    
    This file is part of Urh Dungeon 2.

    Urh Dungeon 2 is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Urh Dungeon 2 is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Urh Dungeon 2.  If not, see <http://www.gnu.org/licenses/>.
"""

import pygame

fontt = "data/info.ttf"

def printSurface(surface, text, size, color, coor, center=False, bg=None):
    font = pygame.font.Font(fontt, size)
    texts = font.render(text, 1, color)
    if not center:
        textpos = coor
    else:
        textpos = texts.get_rect(center=coor)
    if bg:
        tmp = pygame.Surface((texts.get_width(),texts.get_height()))
        tmp.fill(bg)
        tmp.blit(texts, (0,0))
        texts = tmp
    surface.blit(texts, textpos)
    return texts.get_width()
